Program generation apparatus

ABSTRACT

A program generation apparatus for generating light-weight class files for each terminal apparatus by linking class files. The program generation apparatus includes: a storage unit for prestoring the class files for each terminal apparatus, where each class defines (a) dependent variables unique to each terminal apparatus and (b) non-dependent variables common to all the terminal apparatuses, each variable is identified by a variable name, and each class file includes a variable name for each variable; an assignment unit for assigning an offset number to each variable defined in the class files so that the same offset numbers are assigned to non-dependent variables having the same variable names; and a generation unit for generating the light-weight class files for each terminal apparatus by replacing each variable name in each class file with an offset number assigned by the assignment unit.

[0001] This application is based on an application No.2000-43499 filed in Japan, the content of which is hereby incorporated by reference.

BACKGROUND OF THE INVENTION

[0002] (1) Field of the Invention

[0003] The present invention relates to a technique for generating an execution program from source programs written in an object-oriented language and executing the execution program.

[0004] (2) Description of Related Art

[0005] Currently, there are various program execution systems which generate execution programs by compiling and linking source programs that are written in programming languages by users. The generated execution programs are executed in computer-integrated systems such as mobile telephones, Set Top Boxes (STBs), televisions or the like, or executed in personal computers (hereinafter referred to as PCs).

[0006] The following is a description of a conventional program execution system that allows the computer-integrated systems to operate based on a source program written in Java (Java is a trade mark of Sun Microsystems), an object-oriented language.

[0007] The conventional program execution system is composed of a program generation apparatus and a terminal apparatus which is a computer-integrated system.

[0008] The program generation apparatus compiles (1) source programs of one user class, and (2) programs stored in base libraries provided for different terminal apparatuses, and links the programs to generate a different light-weight user class file for each terminal apparatus. Here, the base library includes a group of files which constitute a program that depends on a terminal apparatus and is directly related to control of hardware units inherent in the terminal apparatus, such as a program for controlling the data communications or display on a display unit.

[0009] The light-weight user class file generated for each terminal apparatus is stored in the terminal apparatus, and each terminal apparatus operates according to its own user class file.

[0010] Now, the conventional program execution system will be described in detail using two types of terminal apparatuses A and B which differ from each other in terms of a part of the hardware construction. Here, it is supposed that light-weight user class files are generated from source programs of the same user class, and that the generated user class files are executed in the corresponding terminal apparatuses.

[0011]FIGS. 1 and 2 show examples of source programs written in Java from which base class files that respectively allow the terminal apparatuses A and B perform the same process is generated. FIG. 3 shows an example of a source program written in Java from which a user class file that is used by the terminal apparatuses A and B in common is generated. It should be noted here that in these figures, only field definitions are shown, and descriptions related to detailed use of these fields in methods are omitted.

[0012] As shown in FIG. 1, the class Built_in_classX includes instance fields “privateX1”, “privateX2”, and “privateX3” and instance fields “fieldX1” and “fieldX2”. The instance fields “privateX1”, “privateX2”, and “privateX3” each include a modifier “private”, which indicates that accesses from methods included in other classes are prohibited. The instance fields “fieldX1” and “fieldX2” can be accessed from other classes.

[0013] Also, the class Built_in_classY includes instance fields “privateY1” and “privateY2” and instance fields “fieldY1”, “fieldY1”, “fieldY2”, and “fieldY3”. Since the instance fields “privateY1” and “privateY2” have a modifier “private”, accesses from methods included in other classes to these instance fields are prohibited. The instance fields “fieldY1”, “fieldY2”, and “fieldY3” can be accessed from other classes.

[0014] The class Built_in_classX shown in FIG. 2 includes (1) instance field “privateX1” which cannot be accessed from methods included in other classes and (2) instance fields “fieldX1” and “fieldX2” which can be accessed from other classes. Also, the class Built_in_classY shown in FIG. 2 includes (1) instance field “privateY1”, “privateY2”, and “privateY3” which cannot be accessed from methods included in other classes and (2) instance fields “fieldY1”, “fieldY2”, and “fieldY3” which can be accessed from other classes.

[0015] In each of the above source programs, the class Built_in_classX is inherited by the class Built_in_classY, and the class Built_in_classY is inherited by the class User_class.

[0016] For each of the terminal apparatuses A and B, a class Built_in_classX and a class Built_in_classY are compiled to generate one base class file.

[0017] As understood from above, both terminal apparatuses A and B use a class Built_in_classX and a class Built_in_classY which provide the same function for either of the terminal apparatuses A and B, respectively. The instance fields used in both the two classes, such as “fieldX1”, “fieldX2”, “fieldY1”, “fieldY2”, and “fieldY3” can be accessed by other classes and provide the same contents for either of the class Built_in_classX and class Built_in_classY.

[0018] The two classes also include a different number of instance fields that include different contents and cannot be accessed from other classes. For example, the class Built_in_classX for terminal apparatus A uses “privateX1”, “privateX2”, and “privateX3”; and the class Built_in_classX for terminal apparatus B uses only “privateX1”.

[0019] Note here that the “privateX1”s for terminal apparatuses A and B have the same name but different contents. This also applies to the “privateyl”s and “privateY2”s.

[0020] The instance fields “privateX1”, “privateX2”, “privateX3”, “privateY1”, and “privateY2” for terminal apparatus A and the instance fields “privateX1”, “privateY1”, “privateY2”, and “privateY3” for terminal apparatus B are defined with the modifier “private”, are used to exercise control according to the hardware of each of the terminal apparatuses A and B, and depend on the base class design of the terminal apparatus. Hereinafter, these instance fields are therefore referred to as class-design-dependent fields.

[0021] The other instance fields “fieldX1”, “fieldX2”, “fieldY1”, “fieldY2”, and “fieldY3” commonly used by the terminal apparatuses A and B are used to exercise control common to the terminal apparatuses A and B, and are not dependent on the base class design of the terminal apparatus. Hereinafter, these instance fields are referred to as class-design-non-dependent fields.

[0022] A class User_class is compiled to become a user class file. As shown in FIG. 3, the class User_class uses instance fields “fieldU1” and “fieldU2”.

[0023] FIGS. 4 to 7 shows instance field offset tables of the above class Built_in_classXs, class Built_in_classYs, and class User_class. Each instance field offset table includes unique numbers assigned to the instance fields by the conventional program generation apparatus.

[0024]FIGS. 4 and 5 show instance field offset tables for base class files. FIGS. 6 and 7 show instance field offset tables for user class files. FIGS. 4 and 6 correspond to the terminal apparatus A, and FIGS. 5 and 7 correspond to the terminal apparatus B.

[0025] As shown in FIGS. 4 and 5, the instance field offset tables of the class Built_in_classYs include the instance fields inherited from the class Built_in_classXs, with the same offset numbers assigned. More specifically, for the terminal apparatus A, the same offset numbers as the class Built_in_classX are assigned to the instance fields “fieldX1”, “fieldX2”, “privateX1”, “privateX2”, and “privateX3”; and for the terminal apparatus B, the same offset numbers as the class Built_in_classX are assigned to the instance fields “fieldX1”, “fieldX2”, and “privateX1”.

[0026] As shown in FIGS. 6 and 7, the instance field offset tables of the classes “User_class” include the instance fields inherited from the class Built_in_classYs, with the same offset numbers assigned. More specifically, for the terminal apparatus A, the same offset numbers as the class Built_in_classY are assigned to the instance fields “fieldX1”, “fieldX2”, “privateX1”, “privateX2”, “privateX3”, “fieldY1”, “fieldY2”, “fieldY3”, “privateY1”, and “privateY2”. This also applies to the terminal apparatus B.

[0027] As shown in FIG. 6, in the instance field offset table for the terminal apparatus A, offset numbers “11” and “12” are assigned to the instance fields “fieldU1” and “fieldU2”, while as shown in FIG. 7, in the instance field offset table for the terminal apparatus B, offset numbers “10” and “11” are assigned to the instance fields “fieldU1” and “fieldU2”.

[0028] The program generation apparatus modifies each class file according to the instance field offset tables. More specifically, instance field names used as operands in the instructions included in each class file are replaced with the corresponding offset numbers, and identification information corresponding to the instance fields are deleted from the constant pool in the class file. In this way, a different light-weight user class file is generated for each terminal apparatus from source programs of the same user class.

[0029] The conventional program execution system, however, needs to link as many times as there are types of terminal apparatuses (i.e., types of light-weight base classes) even if source programs of the same user class are used.

SUMMARY OF THE INVENTION

[0030] It is therefore an object of the present invention to provide a program generation apparatus, a program generation method, a record medium recording a program generation program, a virtual machine, a program execution method, a record medium recording a program execution program, and a record medium recording a program generated by the program generation apparatus for generating an execution program from a source program written in a object-oriented language, where a different set of base classes are prepared for each terminal apparatus, and an execution program for each terminal apparatus is generated, characterized in that when a common program is compiled and linked, linkage for each terminal apparatus is not necessary.

[0031] The above object is fulfilled by a program generation apparatus for generating a plurality of light-weight class files for each terminal apparatus by linking a plurality of class files for each terminal apparatus, the program generation apparatus comprising: a storage means for prestoring the plurality of class files for each terminal apparatus, wherein each class defines (a) dependent variables unique to each terminal apparatus and (b) non-dependent variables common to all the plurality of terminal apparatuses, each variable is identified by a variable name, and each class file includes a variable name for each variable; an assignment means for assigning an offset number to each variable defined in the plurality of class files so that the same offset numbers are assigned to non-dependent variables having the same variable names; and a generation means for generating the plurality of light-weight class files for each terminal apparatus by replacing each variable name in each class file with an offset number assigned by the assignment means.

[0032] With the above construction, a different offset number is generated for each variable defined in the class files stored in the storage means so that the same offset numbers are assigned to non-dependent variables having the same variable names in different terminal apparatuses when linkage is performed for each terminal apparatus. Light-weight class files are then generated using the generated offset numbers. Therefore, when a common program is compiled and linked, the light-weight class files are generated, eliminating the necessity of linkage for each terminal apparatus.

[0033] In the above program generation apparatus, the assignment means may assign an offset number to each variable using different numbering systems for dependent variables and non-dependent variables.

[0034] With the above construction, offset numbers are assigned using different numbering systems for dependent variables and non-dependent variables. Therefore, the same offset numbers are definitely assigned to non-dependent variables having the same variable names in different terminal apparatuses.

[0035] In the above program generation apparatus, the generation means may further generate a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.

[0036] The above construction enables a virtual machine to generate an instance using the non-dependent variable count and the dependent variable count generated for each class and included in the light-weight class files.

[0037] In the above program generation apparatus, the plurality of classes may include a first class and a second class which inherits the first class, and the assignment means assigns an offset number to each variable using, in terms of the second class, different numbering systems for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class.

[0038] With the above construction, an offset number is assigned to each variable using, in terms of the second class, different numbering systems for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class. Therefore, the above dependent variables (a) and (b) can definitely be distinguished from each other.

[0039] In the above program generation apparatus, the generation means may further generate a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.

[0040] The above construction enables a virtual machine to generate an instance using the non-dependent variable count and the dependent variable count generated for each class and included in the light-weight class files.

[0041] In the above program generation apparatus, the plurality of classes may include a first class and a second class which inherits the first class, and the assignment means assigns an offset number to each variable using, in terms of the second class, one numbering system for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class.

[0042] With the above construction, an offset number is assigned to each variable using, in terms of the second class, one numbering system for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class. This makes the management easier since the number of used numbering systems is less.

[0043] In the above program generation apparatus, the generation means may further generate a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.

[0044] The above construction enables a virtual machine to generate an instance using the non-dependent variable count and the dependent variable count generated for each class and included in the light-weight class files.

[0045] In the above program generation apparatus, the plurality of classes may include a first class and a second class which inherits the first class, and the number assignment means assigns an offset number to each variable using one numbering system regardless of dependent variables or non-dependent variables, and provides, in terms of the second class, a predetermined space between (a) variables defined only in the second class and (b) variables defined in the first class inherited by the second class.

[0046] With the above construction, offset numbers are assigned using one numbering system regardless of dependent variables or non-dependent variables, and in terms of the second class, a predetermined space is provided between (a) variables defined only in the second class and (b) variables defined in the first class inherited by the second class. This makes the management of offset numbers easier.

[0047] In the above program generation apparatus, the generation means further generates a non-dependent variable count for each class, and adds the non-dependent variable count to a dependent variable count being a fixed value to obtain a count, and adds the obtained count to each light-weight class file.

[0048] The above construction enables a virtual machine to generate an instance using the non-dependent variable count and the dependent variable count generated for each class and included in the light-weight class files.

[0049] The above object is also fulfilled by a virtual machine for operating according to a plurality of light-weight class files generated by the above program generation apparatus, comprising: a storage means for prestoring the plurality of light-weight class files; an instance generation means for reading the plurality of light-weight class files and generating an instance according to offset numbers for variables included in the plurality of light-weight class files; and an execution means for executing instructions defined in the plurality of light-weight class files, using the generated instance.

[0050] With the above construction, an instance is generated according to offset numbers for variables included in the light-weight class files generated in the program generation apparatus. This eliminates the necessity of linkage for each terminal apparatus when compiling and linking a common program. Also, the program generated in this way can be executed in each terminal apparatus.

[0051] The above object is also fulfilled by a virtual machine for operating according to a plurality of light-weight class files generated by the above program generation apparatus, comprising: a storage means for prestoring the plurality of light-weight class files; an instance generation means for generating an instance by (a) reading the plurality of light-weight class files, (b) allocating a first area and a second area in a memory based on, respectively, non-dependent variable counts and dependent variable counts generated for each class and included in the read light-weight class files, and (c) storing in the second area a pointer pointing to the first area; and an execution means for executing instructions defined in the plurality of light-weight class files, using the generated instance.

[0052] With the above construction, and instance is generated by allocating the first and second areas in a memory based on the non-dependent variable counts and the dependent variable counts included in the light-weight class files, and storing in the second area a pointer pointing to the first area. This secures the generation of the instance.

BRIEF DESCRIPTION OF THE DRAWINGS

[0053] These and other objects, advantages and features of the invention will become apparent from the following description thereof taken in conjunction with the accompanying drawings which illustrate a specific embodiment of the invention. In the drawings:

[0054]FIG. 1 shows an example of a source program written in Java from which a base class file is generated, the base class file allowing a terminal apparatus A of a conventional program execution system to perform processes;

[0055]FIG. 2 shows an example of a source program written in Java from which a base class file is generated, the base class file allowing a terminal apparatus B of a conventional program execution system to perform processes;

[0056]FIG. 3 shows an example of a source program written in Java from which a user class file that is used by the terminal apparatuses A and B in common is generated;

[0057]FIG. 4 shows an instance field offset table for base class files for terminal apparatus A in the conventional program execution system;

[0058]FIG. 5 shows an instance field offset table for base class files for terminal apparatus B in the conventional program execution system;

[0059]FIG. 6 shows an instance field offset table for user class files for terminal apparatus A in the conventional program execution system;

[0060]FIG. 7 shows an instance field offset table for user class files for terminal apparatus B in the conventional program execution system;

[0061]FIG. 8 is a block diagram showing the construction of a program execution system 1;

[0062]FIG. 9 shows generation of a light-weight base class file 541 by the program generation apparatus 10 from a base class source program 511;

[0063]FIG. 10 shows generation of a light-weight user class file 542 by the program generation apparatus 10 from a user class source program 512;

[0064]FIG. 11 shows class-design-non-dependent field offset tables corresponding to base classes Built_in_classX and Built_in_classY;

[0065]FIG. 12A shows class-design-dependent field offset tables corresponding to the base class Built_in_classX and the base class Built_in_classY for terminal apparatus A;

[0066]FIG. 12B shows class-design-dependent field offset tables corresponding to the base class Built_in_classX and the base class Built_in_classY for terminal apparatus B;

[0067]FIG. 13 shows a class-design-non-dependent field offset table corresponding to user class User_class;

[0068]FIG. 14 shows an instance for user class User_class generated in terminal apparatus A;

[0069]FIG. 15 shows an instance for user class User_class generated in terminal apparatus B;

[0070]FIG. 16A shows a class file for a Java user class before conversion;

[0071]FIG. 16B shows a class file for a Java user class after conversion;

[0072]FIG. 17 shows a Java program which is compiled to base class files;

[0073]FIG. 18 shows operands of the getfield instruction after conversion;

[0074]FIG. 19A shows base class Built_in_classY for terminal apparatus A before conversion;

[0075]FIG. 19B shows base class Built_in_classY for terminal apparatus A after conversion;

[0076]FIG. 20 shows a class ID correspondence table for base classes;

[0077]FIG. 21 shows a class ID correspondence table for user classes;

[0078]FIG. 22 shows an example of a class-design-non-dependent field count table corresponding to a light-weight base class file common to the terminal apparatuses A and B;

[0079]FIG. 23 shows an example of a class-design-non-dependent field count table corresponding to a light-weight user class file common to the terminal apparatuses A and B;

[0080]FIG. 24A shows a class-design-dependent field count table for a light-weight base class file for terminal apparatus A;

[0081]FIG. 24B shows a class-design-dependent field count table for a light-weight base class file for terminal apparatus B;

[0082]FIG. 25 is a flowchart showing the procedure of linkage for base class files;

[0083]FIG. 26 is a flowchart showing a detailed procedure of offset table generation;

[0084]FIG. 27 is a flowchart showing a detailed procedure of instruction conversion;

[0085]FIG. 28 is a flowchart showing the procedure of linkage for user class files;

[0086]FIG. 29 is a flowchart showing a detailed procedure of offset table generation;

[0087]FIG. 30 is a flowchart showing a detailed procedure of instruction conversion;

[0088]FIG. 31 is a flowchart showing the procedure of instruction execution in terminal apparatus 20, continuing to FIG. 32;

[0089]FIG. 32 is a flowchart showing the procedure of instruction execution in terminal apparatus 20, a continuation from FIG. 31;

[0090]FIG. 33 shows an example of a Java program from which class files are generated via compilation;

[0091]FIG. 34A shows an instance generated in the program execution system 1 to correspond to the Java program shown in FIG. 33;

[0092]FIG. 34B shows an instance generated in another program execution system to correspond to the Java program shown in FIG. 33;

[0093]FIG. 35 shows an example of a Java program from which class files are generated via compilation;

[0094]FIG. 36A shows operands of the getfield instruction after conversion which correspond to the Java program shown in FIG. 35 for class A;

[0095]FIG. 36B shows operands of the getfield instruction after conversion which correspond to the Java program shown in FIG. 35 for class B;

[0096]FIG. 37 shows two class-design-non-dependent field offset tables that are generated to correspond to base classes in the program execution system 2;

[0097]FIG. 38A shows a class-design-dependent field offset table that is generated to correspond to base classes for terminal apparatus A;

[0098]FIG. 38B shows a class-design-dependent field offset table that is generated to correspond to base classes for terminal apparatus B;

[0099]FIG. 39 shows the class-design-non-dependent field offset table corresponding to the user class User_class shown in FIG. 3;

[0100]FIG. 40A shows an instance corresponding to the user classes User_class generated in the terminal apparatus A;

[0101]FIG. 40B shows an instance corresponding to the user classes User_class generated in the terminal apparatus B;

[0102]FIG. 41 shows a class-design-non-dependent field count table included in a light-weight base class file for the terminal apparatuses A and B;

[0103]FIG. 42A shows a class-design-dependent field count table included in light-weight base class files for the terminal apparatus A;

[0104]FIG. 42B shows a class-design-dependent field count table included in light-weight base class files for the terminal apparatus B;

[0105]FIG. 43 shows a class-design-non-dependent field count table included in a light-weight user class file for the terminal apparatuses A and B;

[0106]FIG. 44A shows a class file, before conversion, for the base class Built_in_classY for the terminal apparatus A;

[0107]FIG. 44B shows a class file, after conversion, for the base class Built_in_classY for the terminal apparatus A;

[0108]FIG. 45A shows a class file for the user class before conversion;

[0109]FIG. 45B shows a class file for the user class after conversion;

[0110]FIG. 46 is a flowchart showing a detailed procedure of offset table generation by the offset table generation unit 13 in the program execution system 2 during linkage to base class files;

[0111]FIG. 47 is a flowchart showing a detailed procedure of instruction conversion by the instruction conversion unit 14 in the program execution system 2 during linkage to base class files;

[0112]FIG. 48 is a flowchart showing a detailed procedure of offset table generation by the offset table generation unit 13 in the program execution system 2 during linkage to user class files;

[0113]FIG. 49 is a flowchart showing a detailed procedure of instruction conversion by the instruction conversion unit 14 in the program execution system 2 during linkage to user class files;

[0114]FIG. 50 is a flowchart showing the procedure of instruction execution process performed by the terminal apparatus 20, continuing to FIG. 51;

[0115]FIG. 51 is a flowchart showing the procedure of instruction execution process performed by the terminal apparatus 20, a continuation from FIG. 50;

[0116]FIG. 52 shows two class-design-non-dependent field offset tables corresponding to the base classes Built_in_classX and Built_in_classY;

[0117]FIG. 53A shows an instance field offset table for the terminal apparatus A;

[0118]FIG. 53B shows an instance field offset table for the terminal apparatus B;

[0119]FIG. 54 shows an instance field offset table generated in correspondence to the user class User_class shown in FIG. 3;

[0120]FIG. 55A shows an instance of the user class User_class generated by the terminal apparatus A; and

[0121]FIG. 55B shows an instance of the user class User_class generated by the terminal apparatus B.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0122] The following are description of program execution systems as embodiments of the present invention.

[0123] 1. First Embodiment

[0124] The program execution system 1 will be described as the first embodiment of the present invention.

[0125] 1.1 Construction of Program Execution System 1

[0126] The construction of a program execution system 1 will be described with reference to its block diagram shown in FIG. 8.

[0127] The program execution system 1 is, as shown in FIG. 8, composed of a program generation apparatus 10 and a terminal apparatus (i.e., light virtual machine) 20 which is a computer-integrated system. The program generation apparatus 10 includes a compiling unit 11, a static linkage unit 12, and a storage unit which is not illustrated. The terminal apparatus 20 includes an instruction execution unit 21, an instance generation unit 22, and a storage unit which is not illustrated.

[0128] The program generation apparatus 10 and terminal apparatus 20 are both computer systems including a microprocessor, a RAM, a ROM or the like, where the RAM or ROM stores a computer program. The functions of the program generation apparatus 10 and terminal apparatus 20 are achieved as the microprocessor operates according to the computer program.

[0129] It should be noted that though the compiling unit 11 and static linkage unit 12 are included in one program generation apparatus 10, they may be included in different apparatuses. In this case, either of them may include a program generation unit for generating a light-weight user class file 56.

[0130] (1) Source Program 51

[0131] A source program 51 is stored in the storage unit in the program generation apparatus 10. The source program 51 is written in Java by a user, and includes a plurality of classes. The source program 51 is classified into (a) a program related to base classes and (b) a program related to user classes.

[0132] (2) Base Class Definition Files 55

[0133] A base class definition files 55 are prestored in the storage unit in the program generation apparatus 10. The base class definition files 55 show definitions of classes, methods, and fields included in a light-weight base class library 58 which is prestored in the terminal apparatus 20. The base class definition files 55 do not include such information as names, types, and counts of class-design-dependent fields.

[0134] (3) Compiling Unit 11

[0135] The compiling unit 11 reads the source program 51 from the storage unit, compiles the source program 51, and generates class files 52, . . . , 53 which correspond to classes included in the source program 51. The class files 52, . . . , 53 are classified into (a) those related to base classes and (b) those related to user classes. The compiling unit 11 writes the generated class files 52, . . . , 53 into the storage unit.

[0136] (4) Static Linkage Unit 12

[0137] The static linkage unit 12 reads the class files 52, . . . , 53 and base class definition files 55 from the storage unit, uses the base class definition files 55 as necessary, performs a linkage concerning identification information in the constant pool in the class files 52, . . . , 53, deletes pieces of identification information, which has become unnecessary due to the size reduction, to generate light-weight class files 54 . . . and writes the light-weight class files 54 . . . into the storage unit.

[0138] The light-weight class files 54 . . . are classified into (a) light-weight base class files and (b) light-weight user class files. The light-weight base class files are light-weight class files related to the construction and control of the hardware inherent in the terminal apparatus 20. The light-weight user class files are light-weight class files as user class files.

[0139] The static linkage unit 12 is composed of an offset table generation unit 13, an instruction conversion unit 14, and a linkage unit 15.

[0140] The offset table generation unit 13 assigns offset numbers to instance fields used in class files. The offset table generation unit 13 includes a non-dependent table generation unit 131 and a dependent table generation unit 132. The non-dependent table generation unit 131 generates class-design-non-dependent field offset tables which correspond to class-design-non-dependent fields which do not depend on the design of the terminal apparatus hardware (i.e., base classes). The dependent table generation unit 132 generates class-design-dependent field offset tables which correspond to class-design-dependent fields which depend on the design of the terminal apparatus hardware. The offset table generation unit 13 generates a count table, and writes the generated count table into a light-weight class file.

[0141] The instruction conversion unit 14 converts offsets into offset numbers, where the offsets are included in a constant pool and indicate instance fields included in class files.

[0142] The linkage unit 15 performs other linkage processes.

[0143] (5) Light-Weight User Class File 56, Light-Weight Base Class File 57

[0144] Light-weight base class files are stored as light-weight base class files 57 into the terminal apparatus 20 prior to execution of light-weight user class files 56. Light-weight user class files are distributed via a certain transmission line, then downloaded and stored into the terminal apparatus 20.

[0145] The light-weight base class library 58 prestores a plurality of light-weight base class files as a file group. The light-weight user class files stored in the terminal apparatus 20 have already been linked with the light-weight base class files included in the light-weight base class library 58 that are specified by the light-weight user class files 56. In other words, identification information for the files has been reduced in size.

[0146] (6) Instruction Execution Unit 21, Instance Generation Unit 22

[0147] The instruction execution unit 21 calls an instruction from a light-weight user class file 56, and executes the instruction. In doing this, the instruction execution unit 21 calls a light-weight base class file 57 and executes it. The instance generation unit 22 generates instances as it executes instructions.

[0148] 1.2 Operation of Program Generation Apparatus 10

[0149] The operation of the program generation apparatus 10 in generating light-weight base class files and light-weight user class files will be described with reference to FIGS. 9 and 10.

[0150] (1) Generating Light-Weight Base Class Files

[0151]FIG. 9 shows an operation of the program generation apparatus 10 when it generates light-weight base class files 541 from base class source programs 511.

[0152] The compiling unit 11 compiles the base class source programs 511 to generate base class files 521, . . . , 522. The non-dependent table generation unit 131 in the static linkage unit 12 generates class-design-non-dependent field offset tables shown in FIG. 11 from the base class files 521, . . . , 522. The dependent table generation unit 132 in the static linkage unit 12 generates class-design-dependent field offset tables shown in FIG. 12 from the base class files 521, . . . , 522. The instruction conversion unit 14 converts, in accordance with the tables shown in FIGS. 11 and 12, the offsets in the constant pool into offset numbers which are assigned when each table is generated. Note that the offsets in the constant pool indicate instance fields used as operands in certain instructions such as the getfield instruction and the putfield instruction. The linkage unit 15 performs other linkage processes.

[0153] The offset table generation unit 13 collects definitions of classes, methods, and fields from the base class files 521, 522, and stores the collected definitions into the base class definition files 55. As described earlier, the base class definition files 55 do not include such information as names, types, and counts of class-design-dependent fields, and the contents of the generated base class definition files 55 are the same regardless of the type of each terminal.

[0154] (2) Generating Light-Weight User Class Files

[0155]FIG. 10 shows an operation of the program generation apparatus 10 when it generates light-weight user class files 542 from user class source programs 512.

[0156] After generating the light-weight base class files, the compiling unit 11 compiles the user class source programs 512 to generate user class files 531, . . . , 532. The non-dependent table generation unit 131 in the static linkage unit 12 generates class-design-non-dependent field offset tables shown in FIG. 13 from the user class files 531, . . . , 532 and the generated base class definition files 55. The instruction conversion unit 14 converts, in accordance with these tables, the offsets in the constant pool into offset numbers which are assigned when each table is generated. Note that the offsets in the constant pool indicate instance fields used as operands in certain instructions. The linkage unit 15 performs other linkage processes.

[0157] (3) Brief Account

[0158] The base class definition files 55 for each program execution system 1 of the present embodiment are unique to the system 1, and do not depend on the construction of the light-weight base class files of the terminal apparatus 20. The static linkage unit 12 links user class files to base class files using the base class definition files 55. Also, the static linkage unit 12 generates the same light-weight user class files 542 from the source programs 512 of the same user class for a plurality of different terminal apparatuses so that the class-design-non-dependent field offset tables, or the instance field offset tables for the light-weight user class files do not include information related to the class-design-dependent fields, by using a pointer or the like.

[0159] 1.3 Field Offset Table

[0160] The following is a detailed description of (a) the class-design-dependent or -non-dependent field offset tables for the light-weight base class files and (b) the class-design-non-dependent field offset tables for the light-weight user class files, with reference to FIGS. 11 to 13.

[0161] Each field offset table is generated by the program generation apparatus 10, and includes an area for storing a plurality of pairs of a field offset number and an instance field.

[0162] The above field offset tables are used by the instruction conversion unit 14 when it converts the getfield instruction and the putfield instruction, and are discarded when the static linkage unit 12 ends the process.

[0163] As is the case with the conventional program execution system, it is supposed here that two types of terminal apparatuses A and B which differ from each other in terms of a part of the hardware construction execute light-weight user class files which are generated from source programs of the same user class. It is also supposed that storage unit of the program generation apparatus 10 stores the Java programs shown in FIGS. 1 to 3.

[0164] (1) Class-Design-Non-Dependent Field Offset Tables for Base Classes

[0165]FIG. 11 shows two class-design-non-dependent field offset tables that are generated to correspond to the base class Built_in_classX and the base class Built_in_classY shown in FIGS. 1 and 2, respectively.

[0166] The non-dependent table generation unit 131 in the static linkage unit 12 generates the class-design-non-dependent field offset tables to correspond to the base class Built_in_classX and the base class Built_in_classY shown in FIGS. 1 and 2, respectively.

[0167] As shown in the class-design-non-dependent field offset table shown in FIG. 11 that corresponds to the base class Built_in_classX shown in FIG. 1, the non-dependent table generation unit 131 assigns field offset numbers “2” and “3” to the class-design-non-dependent fields “fieldX1” and “fieldX2”, respectively, in the order of definition. The non-dependent table generation unit 131 writes “null” in the area in the “instance field” column corresponding to the field offset number “1”, where the instance field “null” stores a pointer when a terminal apparatus generates instances, the pointer pointing to an area corresponding to a class-design-dependent field offset table.

[0168] As shown in the class-design-non-dependent field offset table shown in FIG. 11 that corresponds to the base class Built_in_classY, the non-dependent table generation unit 131 assigns field offset numbers “2” and “3” to the class-design-non-dependent fields “fieldX1” and “fieldX2” in the same manner as the base class Built_in_classX, where these fields are inherited from the base class Built-in_classX. The non-dependent table generation unit 131 assigns offset numbers “5”, “6”, and “7” to the class-design-non-dependent fields “fieldyl”, “fieldY2”, and “fieldY3”, respectively, in the order of definition, where these fields are newly defined in the base class Built_in_classY. The non-dependent table generation unit 131 writes “null” in the area in the “instance field” column corresponding to the field offset number “1”, where the instance field “null” stores a pointer when a terminal apparatus generates instances, the pointer pointing to the same area as the pointer stored in the instance field “null” shown in the class-design-non-dependent field offset table for the base class Built_in_classX when a terminal apparatus generates instances. The non-dependent table generation unit 131 also writes “null” in the area in the “instance field” column corresponding to the field offset number “4”, where this instance field “null” stores a pointer when a terminal apparatus generates instances, the pointer pointing to an area corresponding to a class-design-dependent field offset table that corresponds to class-design-dependent fields defined in the base class Built_in_classy.

[0169] (2) Base Class Class-Design-Dependent Field Offset Tables

[0170]FIG. 12 shows class-design-dependent field offset tables corresponding to the base class Built_in_classX and the base class Built_in_classY.

[0171] The class-design-non-dependent field offset tables are common to the terminal apparatuses A and B, while different class-design-dependent field offset tables are used for the terminal apparatuses A and B since different class-design-dependent fields are used. The dependent table generation unit 132 generates the class-design-dependent field offset tables shown in FIG. 12A for the terminal apparatus A in correspondence to different base classes, respectively, and generates the class-design-dependent field offset tables shown in FIG. 12B for the terminal apparatus B.

[0172] As described above, when the light-weight base class files 541 are generated, class-design-non-dependent field offset tables and class-design-dependent field offset tables are generated for each of the base class Built_in_classX and Built_in_classY.

[0173] (3) User Class Class-Design-Non-Dependent Field Offset Tables

[0174] When the light-weight user class file 542 shown in FIG. 10 is generated, the class-design-non-dependent field offset table corresponding to the user class User_class shown in FIG. 13 is generated, and the instances shown in FIGS. 14 and 15 are generated according to executions in the terminal apparatus 20.

[0175]FIG. 13 shows the class-design-non-dependent field offset table corresponding to the user class User_class shown in FIG. 3. FIGS. 14 and 15 show the instances corresponding to the user classes User_class generated in the terminal apparatuses A and B, respectively.

[0176] The non-dependent table generation unit 131 in the static linkage unit 12 generates a class-design-non-dependent field offset table to correspond to the user class User_class.

[0177] As shown in FIG. 13, the non-dependent table generation unit 131 assigns field offset numbers “2”, “3”, “5”, “6”, and “7” respectively to the class-design-non-dependent fields “fieldX1”, “fieldX2”, “fieldY1”, “fieldY2”, and “fieldY3” which are inherited from the base class Built_in_classY. The non-dependent table generation unit 131 assigns offset numbers “8” and “9” to the newly defined class-design-non-dependent fields “fieldU1” and “fieldU2”, respectively, in the order of definition. The non-dependent table generation unit 131 writes “null” in the areas in the “instance field” column corresponding to the field offset numbers “1” and “4”, where the instance fields “null” stores pointers when terminal apparatuses generate instances, the pointers pointing to the same areas as the pointers stored in the instance fields “null” shown in the class-design-non-dependent field offset tables for the base classes Built_in_classX and Built_in_classY when terminal apparatuses generate instances.

[0178] 1.4 Generated Instances

[0179] The instance generation unit 22 of the terminal apparatus 20 generates the instances shown in FIGS. 14 and 15.

[0180] The instance generation unit 22 of the terminal apparatus A first allocates a memory area 701 corresponding to the class-design-non-dependent field offset table shown in FIG. 13. This will be described in detail later. The instance generation unit 22 then allocates memory areas 702 and 703 corresponding to the class-design-dependent field offset tables shown in FIG. 12A. The memory area 701 includes two pointer areas corresponding to instance fields “null”. The instance generation unit 22 stores two different pointers in the two pointer areas, where the first pointer points to the memory area 702 that corresponds to the class-design-dependent field offset table for the base class Built_in_classX, and the second pointer points to the memory area 703 that corresponds to the class-design-dependent field offset table for the base class Built_in_classY. In this way, the instance generation unit 22 generates instances.

[0181] Similarly, the instance generation unit 22 of the terminal apparatus B allocates a memory area 711 corresponding to the class-design-non-dependent field offset table shown in FIG. 13, then allocates memory areas 712 and 713 corresponding to the class-design-dependent field offset tables shown in FIG. 12B. The memory area 711 includes two pointer areas corresponding to instance fields “null”. The instance generation unit 22 stores two different pointers in the two pointer areas, where the first pointer points to the memory area 712 that corresponds to the class-design-dependent field offset table for the base class Built_in_classX, and the second pointer points to the memory area 713 that corresponds to the class-design-dependent field offset table for the base class Built_in_classY. In this way, the instance generation unit 22 generates instances.

[0182] With the above construction, both terminal apparatuses A and B can access “fieldU1” of the user class User_class as the 8^(th) variable in the area corresponding to the instance.

[0183] In the program execution system 1 with the terminal apparatus 20 generating the instances as described above, the instruction conversion unit 14 of the static linkage unit 12 converts the operands in the getfield and putfield instructions corresponding to the class-design-non-dependent fields, as shown in FIG. 16.

[0184] More specifically, as shown in FIG. 16A, in the class file for an ordinary Java user class before conversion, operand <User_class.fieldU1> of the putfield instruction and operand <User_class.fieldU2> of the getfield instruction indicate offsets in the constant pool. The instruction conversion unit 14 converts the offsets into offset numbers that identify instance fields in the instance field, based on the above described instance field offset tables. The instruction conversion unit 14 also converts operand <User_class> of the “new” instruction into a certain number. As a result of this, the class file shown in FIG. 16B is obtained. As shown in FIG. 16B, the operands of the putfield and getfield instructions are converted into “8” and “9”.

[0185] The instruction conversion unit 14 further converts the operands of the putfield and getfield instructions corresponding to class-design-dependent fields.

[0186]FIG. 17 shows a Java program which is compiled to base class files. It should be noted here that FIG. 17 shows only definitions of fields and omits descriptions concerning specific uses. FIG. 18 shows the operands of the getfield instruction after the above conversion, corresponding to the instance fields shown in FIG. 17. Note that this applies to the operands of the putfield instruction.

[0187] As shown in FIG. 17, class A defines class-design-non-dependent fields “fieldA1”, “fieldA2” and “fieldA3”, and class-design-dependent field “fieldA4”. The instruction conversion unit 14 converts operands <A.fieldA1>, <A.fieldA2>, and <A.fieldA3> of the getfield instruction corresponding to “fieldA1”, “fieldA2”, and “fieldA3” and indicating offsets in the constant pool into offset numbers “2”, “3”, and “4” identifying instance fields in the instance area. The instruction conversion unit 14 also converts “getfield <A.fieldA4>” into “dependent getfield 1 1” using prefix “dependent”, where operand <A.fieldA4> of the getfield instruction corresponds to “fieldA4” and indicates an offset in the constant pool. Here, the first operand in the getfield instruction indicates an offset number in the class-design-non-dependent field, and the second operand indicates an offset number in the class-design-dependent field.

[0188] More specifically, as shown in FIG. 19A, in the class file for the base class Built_in_classY for the terminal A, operand <Built_in_classY.fieldU1> of the putfield instruction and operand <Built_in_classY.privateY1> of the getfield instruction indicate offsets in the constant pool. The instruction conversion unit 14 converts the offsets into offset numbers that identify instance fields in the instance field, based on the above described instance field offset tables. The instruction conversion unit 14 also converts operand <Built_in_classY> of the “new” instruction into a certain number. As a result of this, the class file shown in FIG. 19B is obtained.

[0189] 1.5 Class ID Correspondence Table

[0190] The class ID correspondence table is a data table that stores class names and class IDs which are corresponded to each other.

[0191] The class ID (class identifier) is a number used for identifying a class in the light-weight class file. Each class ID uniquely corresponds to a class. Base classes are assigned with serial numbers from “1” to “7FFF”. User classes are assigned with serial numbers from “8001” to “FFFF”.

[0192] The class ID correspondence table is used by the instruction conversion unit 14 when it converts the “new” instruction. The class ID is discarded when the static linkage unit 12 ends processing.

[0193]FIGS. 20 and 21 show class ID correspondence tables. The base class ID correspondence table shown in FIG. 20 stores class names and class IDS of base classes, the class names and class IDs being corresponded to each other. The user class ID correspondence table shown in FIG. 21 stores class names and class IDs of user classes, the class names and class IDs being corresponded to each other.

[0194] 1.6 Field Count Table

[0195] The field count table is classified into a class-design-non-dependent field count table and a class-design-dependent field count table.

[0196] (1) Class-Design-Non-Dependent Field Count Table

[0197] The class-design-non-dependent field count table is a data table that stores class IDs, non-dependent field counts, and super class IDs corresponded to each other.

[0198] The class IDs have been described earlier.

[0199] The non-dependent field count indicates the number of non-dependent fields in a class identified by the class ID.

[0200] The super class ID indicates a class ID of a super class of a class identified by the class ID.

[0201]FIGS. 22 and 23 show class-design-non-dependent field count tables.

[0202] The class-design-non-dependent field count table shown in FIG. 22 corresponds to a light-weight base class file common to the terminal apparatuses A and B.

[0203] The class-design-non-dependent field count table shown in FIG. 23 corresponds to a light-weight user class file common to the terminal apparatuses A and B.

[0204] (2) Class-Design-Dependent Field Count Table

[0205] The class-design-dependent field count table is a data table that stores class IDs, non-dependent field offsets, dependent field counts, and super class IDs corresponded to each other.

[0206] The class IDs have been described earlier.

[0207] The non-dependent field offset indicates an offset number of a non-dependent field in a class identified by the class ID.

[0208] The dependent field count indicates the number of dependent fields in a class identified by the class ID.

[0209] The super class ID indicates a class ID of a super class of a class identified by the class ID.

[0210]FIGS. 24A and 24B show class-design-dependent field count tables.

[0211] The class-design-dependent field count table shown in FIG. 24A corresponds to a light-weight base class file for the terminal apparatus A.

[0212] The class-design-dependent field count table shown in FIG. 24B corresponds to a light-weight base class file for the terminal apparatus B.

[0213] 1.7 Operation of Program Execution System 1

[0214] The operation of program execution system 1 is achieved when the program generation apparatus 10 and the terminal apparatus 20 exercise the control shown in the flowcharts of FIGS. 25 to 30.

[0215] (1) Operation of Linkage to Base Class File

[0216] The procedure for the linkage to the base class files will be described using the flowcharts shown in FIGS. 25 to 27.

[0217] The static linkage unit 12 reads a base class file specified by a user (step S101), judges whether a yet-to-be-read class file is used in an already-read class file. When judging positively (“Yes” in step S102), the static linkage unit 12 reads the yet-to-be-read class file (step S103), returns to step S102 and repeats reading a base class file until it judges negatively in step S102.

[0218] When judging that a yet-to-be-read class file is not used in an already-read class file (“No” in step S102), the offset table generation unit 13 generates an offset table (step S104 a). The instruction conversion unit 14 performs the instruction conversion process (step S104 a). The linkage unit 15 performs other linkage processes (step S112). The static linkage unit 12 writes a light-weight base class file into a storage unit (step S113), and writes a base class definition file into a storage unit (step S114).

[0219] In this way, the linkage process for base class files is performed to generate a light-weight base class file and a base class definition file.

[0220] Operation of Offset Table Generation Unit 13

[0221] Now, the offset table generation process in step S104 a of the above procedure will be described in detail using the flowchart shown in FIG. 26.

[0222] The offset table generation unit 13 picks up a class, among read classes, for which the instance field offset table has not been generated, and sets the picked-up class as a target (step S104). The offset table generation unit 13 then judges whether it is true that the target class does not have a super class. When the target class has a super class, the offset table generation unit 13 judges whether the instance field offset table has been generated for the super class (step S105).

[0223] When judging positively in step S105, the offset table generation unit 13 assigns a class ID, which is one of serial numbers starting with “1”, to the target class (step S107 a), writes the name and ID of the target class into the base class ID correspondence table shown in FIG. 20 (step S107 b), writes a pointer to a dependent field and a non-dependent field of the target class into the class-design-non-dependent field offset table for the super class shown in FIG. 11, and outputs the class-design-non-dependent field offset table to the instruction conversion unit 14. In this step, when the target class does not have a super class, the offset table generation unit 13 generates a class-design-non-dependent field offset table from the non-dependent field of the target class (step S107 c). The offset table generation unit 13 then writes the class ID, non-dependent field count, and super class ID of the target class into the class-design-non-dependent field count table shown in FIG. 22. In doing this, the non-dependent field count is obtained by counting the non-dependent fields based on the class-design-non-dependent field offset table, including the number of pointer areas and non-dependent fields which are inherited from other classes (step S107 d).

[0224] The offset table generation unit 13 then generates the class-design-dependent field offset table shown in FIG. 12 using only dependent fields of the target class, and outputs the table to the instruction conversion unit 14 (step S108 a). The offset table generation unit 13 writes the class ID, non-dependent field offset, non-dependent field count, and super class ID of the target class into the class-design-dependent field count table shown in FIG. 24. In doing this, the non-dependent field count is obtained by counting only the dependent fields of the target class based on the generated class-design-dependent field offset table. When the target class does not have a super class, the offset table generation unit 13 writes “0” as the super class ID (step S108 b).

[0225] The offset table generation unit 13 then judges whether there is a class for which the instance field offset table has not been generated. When judging it positively (“Yes” in step S109), the offset table generation unit 13 returns to step S104 to repeat the above steps; and when judging it negatively, the offset table generation unit 13 ends the process.

[0226] When judging negatively in step S105, the offset table generation unit 13 sets the super class as a target (step S106), and returns to step S105.

[0227] Operation of Instruction Conversion Unit 14

[0228] The instruction conversion in step S110 a will be described in detail with reference to the flowchart shown in FIG. 27.

[0229] The instruction conversion unit 14 judges whether there is an unconverted operand of the getfield or putfield instruction. When judging it positively (“Yes” in step S110), the instruction conversion unit 14 judges whether the instruction including the operand is a dependent field access instruction. When judging it positively (“Yes” in step S111 a), the instruction conversion unit 14 performs the instruction conversion by adding the dependent modification instruction to the access instruction, and referring to the dependent field count table of the target class to set the non-depended field offset to the first operand, and referring to the dependent field offset table of the target class to set the depended field offset to the second operand (step S111 c), and then returns to step S110.

[0230] When judging it negatively in step S111 a, the instruction conversion unit 14 performs the instruction conversion by referring to the non-dependent field offset table of the target class to set the non-dependent field offset to the first operand (step S111 b), and then returns to step S110.

[0231] When judging it negatively in step S110, the instruction conversion unit 14 judges whether there is a “new” instruction yet to be processed. When judging it positively (“Yes” in step S111 d), the instruction conversion unit 14 refers to the class ID table to perform the instruction conversion by changing the class name to the class ID (step S111 e), and then returns to step S111 d.

[0232] When judging negatively in step S111 d, the instruction conversion unit 14 writes the non-dependent field count table and the dependent field count table (step S111 f), and ends the process of the instruction conversion unit 14.

[0233] (2) Operation of Linkage to User Class File

[0234] The procedure for the linkage to the user class files will be described using the flowcharts shown in FIGS. 28 to 30.

[0235] The static linkage unit 12 reads a user class file specified by a user (step S201), reads a base class definition file (step S202), judges whether a yet-to-be-read class file is used in an already-read class file. When judging positively (“Yes” in step S203), the static linkage unit 12 reads the yet-to-be-read class file (step S204), returns to step S203 and repeats reading a user class file until it judges negatively in step S203.

[0236] When judging that a yet-to-be-read class file is not used in an already-read class file (“No” in step S203), the offset table generation unit 13 generates an offset table (step S205 a). The instruction conversion unit 14 performs the instruction conversion process (step S210 a). The linkage unit 15 performs other linkage processes (step S212). The static linkage unit 12 writes a light-weight user class file into a storage unit (step S213).

[0237] In this way, the linkage process for user class files is performed to generate a light-weight user class file.

[0238] Operation of Offset Table Generation Unit 13

[0239] Now, the offset table generation process in step S205 a of the above procedure will be described in detail using the flowchart shown in FIG. 29.

[0240] The offset table generation unit 13 picks up a class, among read classes, for which the instance field offset table has not been generated, and sets the picked-up class as a target (step S205). The offset table generation unit 13 then judges whether the super class of the target class is a base class. When judging it positively (“Yes” in step S206 a), the offset table generation unit 13 generates a class-design-non-dependent field offset table for the super class from the base class definition file (step S206 b), and moves to step S208 a.

[0241] When judging negatively in step S206 a, the offset table generation unit 13 judges whether the instance field offset table has been generated for the super class of the target class. When judging it positively (“Yes” in step S206 c), the offset table generation unit 13 moves to step S208 a.

[0242] When judging negatively in step S206 c, the offset table generation unit 13 sets the super class as a target (step S207), and returns to step S206 a.

[0243] The offset table generation unit 13 assigns a class ID, which is one of serial numbers starting with “8001”, to the target class (step S208 a), writes the name and ID of the target class into the user class ID correspondence table shown in FIG. 21 (step S208 b), writes a non-dependent field of the target class into the class-design-non-dependent field offset table for the super class shown in FIG. 13, and outputs the class-design-non-dependent field offset table to the instruction conversion unit 14 (step S208 c). The offset table generation unit 13 then writes the class ID, non-dependent field count, and super class ID of the target class into the class-design-non-dependent field count table shown in FIG. 23. In doing this, the non-dependent field count is obtained by counting the non-dependent fields based on the class-design-non-dependent field offset table generated in step S208 c, including the number of non-dependent fields which are inherited from other classes (step S208 d).

[0244] The offset table generation unit 13 then judges whether there is a class for which the instance field offset table has not been generated. When judging it positively (“Yes” in step S209 the offset table generation unit 13 returns to step S205 to repeat the above steps; and when judging it negatively, the offset table generation unit 13 ends the process.

[0245] Operation of Instruction Conversion Unit 14

[0246] The instruction conversion in step S210 a will be described in detail with reference to the flowchart shown in FIG. 30.

[0247] The instruction conversion unit 14 judges whether there is an unconverted operand of the getfield or putfield instruction. When judging it positively (“Yes” in step S210), the instruction conversion unit 14 performs the instruction conversion by referring to the non-dependent field offset table of the target class to set the non-depended field offset to the first operand (step S211 a), and then returns to step S210.

[0248] When judging it negatively in step S210, the instruction conversion unit 14 judges whether there is a “new” instruction yet to be processed. When judging it positively (“Yes” in step S211 b), the instruction conversion unit 14 refers to the class ID table to perform the instruction conversion by changing the class name to the class ID (step S211 c), and then returns to step S211 b.

[0249] When judging negatively in step S211 c, the instruction conversion unit 14 writes the non-dependent field count table (step S211 d), and ends the process of the instruction conversion unit 14.

[0250] Brief Account

[0251] When the class-design-non-dependent field offset table shown in FIG. 13 is generated for a target class, offset numbers are uniquely assigned in series to class-design-non-dependent fields of each class, and an instance is generated by allocating an area for storing a pointer pointing to a class-design-dependent field offset table. Especially, when a class inherits instance fields from its super class, the same offset numbers as the super class are assigned to the instance fields of the class.

[0252] The program execution system 1 uses different tables to manage (a) class-design-dependent fields inherited from a base class and (b) class-design-non-dependent fields inherited from a base class and newly defined. When the static linkage unit 12 performs a linkage process to a user class file, the offset table generation unit 13 allocates a fixed-length area in a class-design-non-dependent field offset table for storing a pointer that points to an area corresponding to a class-design-dependent field offset table when an instance is generated.

[0253] The above area for storing a pointer is allocated in each class-design-non-dependent field offset table in a same manner regardless of the types of the terminal apparatuses. Therefore, the class-design-non-dependent field offset tables do not depend on the types of the terminals. When a light-weight user class file is generated, only class-design-non-dependent field offset tables are generated, and the dependent table generation unit 132 is not used.

[0254] In contrast, when a linkage process to a base class file is performed, the base class definition file is not read, and only the base class file is read. Also, the non-dependent table generation unit 131 generates (a) the class-design-non-dependent field offset tables shown in FIG. 11 and (b) the class-design-dependent field offset tables shown in FIG. 12 which are different for each type of terminal apparatus. As a result of such a linkage process, light-weight class files and base class definition files are output.

[0255] (3) Operation of Instruction Execution by Terminal Apparatus 20

[0256] The procedure for the instruction execution process performed by the terminal apparatus 20 will be described using the flowcharts shown in FIGS. 31 to 32.

[0257] The instruction execution unit 21 reads a light-weight user class file specified by the terminal apparatus 20 into the memory (step S331). The instruction execution unit 21 then judges whether all the instructions in the light-weight user class file in the memory have been selected. When judging it positively (“Yes” in step S300), the instruction execution unit 21 ends the process.

[0258] When judging it negatively (“No” in step S300), the instruction execution unit 21 selects the first instruction among instructions in the light-weight user class file (step S301).

[0259] Executing Outfield Instruction (Getfield Instruction)

[0260] The instruction execution unit 21 judges whether the selected instruction is the putfield (or getfield) instruction. When judging it positively (“Yes” in step S302), the instruction execution unit 21 judges whether “dependent” is attached to the selected instruction (step S314).

[0261] When judging positively in step S314, the instruction execution unit 21 obtains the address of area Y that stores a pointer pointing to a dependent field area, by adding the first operand (a non-dependent field offset) of the selected instruction to an address of an instance in a stack (step S315). The instruction execution unit 21 then obtains the address of area X that is a target of the putfield (getfield) instruction, by adding the second operand (a dependent field offset) of the selected instruction to an address pointed to by the pointer in the area Y (step S316).

[0262] When judging negatively in step S314, the instruction execution unit 21 obtains the address of area X by adding the first operand (a non-dependent field offset) of the selected instruction to an address of an instance in a stack (step S313).

[0263] The instruction execution unit 21 then executes the putfield (getfield) instruction for the area X, and returns to step S301 to repeat the above steps.

[0264] Executing “new” Instruction

[0265] The instruction execution unit 21 judges whether the selected instruction is the “new” instruction. When the instruction execution unit 21 judges it positively (“Yes” in step S303), the instruction generation unit 22 selects a class identified by an ID indicated by an operand of the “new” instruction, as a target class (step S304). The instruction generation unit 22 then reads the class-design-non-dependent field count table from the light-weight user class file, and allocates an area X in a memory having a size enough to store as many fields as indicated by the non-dependent field count for the target class (step S305).

[0266] The instruction generation unit 22 then judges whether the target class is a base class by judging whether the class ID is 7FFF or lower. When the target class is not a base class (“No” in step S306), the instance generation unit 22 identifies a super class by referring to the non-dependent field count table for the light-weight user class file, and sets the identified super class as a target (step S307), and returns to step S306 to repeat the steps.

[0267] When the target class is a base class (“Yes” in step S306), the instance generation unit 22 reads the class-design-dependent field count table from the light-weight base class file, and allocates an area Y in a memory having a size enough to store as many fields as indicated by the dependent field count for the target class (step S308 a), and stores the pointer pointing to the area Y, into an area in the area X indicated by the non-dependent field offset (step S308 b).

[0268] The instance generation unit 22 judges whether the target class has a super class by judging whether it is true that the super class ID in the dependent field count table is not “0”. When judging it positively (“Yes” in step S309), the instance generation unit 22 identifies a super class by referring to the dependent field count table for the light-weight base class file, and sets the identified super class as a target (step S311), and returns to step S308 a to repeat the steps.

[0269] When judging negatively (“No” in step S309), the instance generation unit 22 puts the pointer pointing to the area X onto the stack (step S310), and returns to step S301 to repeat the steps.

[0270] Executing Other Instructions

[0271] When the selected instruction is not the “new” instruction (“No” in step S303), the instruction execution unit 21 executes the selected instruction in the same way as conventional virtual machines (step S312), and returns to step S301 to repeat the steps.

[0272] Brief Account

[0273] The program execution system 1 uses different tables to manage (a) class-design-dependent fields inherited from a base class and (b) class-design-non-dependent fields inherited from a base class and newly defined. When a user class file inherits a base class file that uses a class-design-dependent field, the instance generation unit 22, during an execution of an instruction, allocates different areas to the class-design-non-dependent field offset table and to the class-design-dependent field offset table, and stores a pointer that points to an area corresponding to the class-design-dependent field offset table, into a pointer area in an area corresponding to the class-design-non-dependent field offset table.

[0274] Each class-design-non-dependent field offset table has a pointer area which is identified in the same manner regardless of the terminal apparatus type. As a result, the instance field offset numbers for the class-design-non-dependent fields do not dependent on the terminal type. This enables different types of terminal apparatuses to access the class-design-non-dependent fields of each terminal apparatus, using the same instance field offset numbers. As described earlier, the light-weight user class files including generated count tables do not depend on the type of each terminal. It is therefore possible for the same light-weight user class files to be used by different types of terminal apparatuses.

[0275] In the present embodiment, it is supposed that the instance generation unit 22 of the terminal apparatus 20 in the program execution system 1 allocates an area with the same size to each instance area regardless of the field type. However, the program execution system 1 may allocate an area with a different size to each instance area according to the field type.

1.8 EXAMPLES

[0276] Examples of Java programs used in the program system 1 and generated instances will be described.

[0277] (1) Example 1

[0278]FIG. 33 shows an example of a Java program from which class files are generated via compilation. FIG. 34A shows an instance generated in the program execution system 1 to correspond to the Java program shown in FIG. 33.

[0279] As shown the Java program shown in FIG. 33, class A defines instance fields: int-type “fieldA1”, short-type “fieldA2”, and byte-type “fieldA3”.

[0280] In the program execution system 1, it is supposed that the instance shown in FIG. 34A is generated in correspondence to the above instance fields. In this case, an area with the same size is allocated to each of “fieldA1”, “fieldA2”, and “fieldA3” regardless of the field type.

[0281] On the other hand, in the same program execution system, it is possible to generate the instance shown in FIG. 34B. In this case, an area with a different size is allocated to each of “fieldA1”, “fieldA2”, and “fieldA3” according to the field type, and an offset number is assigned to each field so that the position of the instance area can be identified.

[0282] In the program execution system 1 of the present embodiment, it is supposed that a light-weight class file including a count table including the count of instance fields is transferred to a terminal apparatus, and that the table is referred to when the getfield or putfield instruction is executed. However, the light-weight class file may not include such an instance field offset table, and the getfield instruction and the putfield instruction may include information of an operand type.

[0283] (2) Example 2

[0284]FIG. 35 shows an example of a Java program from which class files are generated via compilation. FIG. 36A shows operands of the getfield instruction after conversion which correspond to the Java program shown in FIG. 35. This also applies to the operands of the putfield instruction.

[0285] It is supposed here that only information indicating the size of the whole instance area is transferred from a program generation apparatus to a terminal apparatus so that the terminal apparatus generates an instance using the “new” instruction. In this example, it is supposed that an instance area with a different size is allocated to each instance field according to the field type. However, an instance area with the same size may be allocated to each instance field regardless of the field type.

[0286] As shown in FIG. 35, class A defines byte-type instance field “fieldA1” and short-type instance field “fieldA2”, and class B defines int-type “fieldBl”. In this example, the operands in the getfield instruction in each class file are converted into instructions as follows: 1-byte (byte-type) operands are converted into getfield_b instructions; 2-byte (short-type) operands are converted into getfield_s instructions; and 4-byte (int-type or reference-type) operands are converted into getfield instructions.

[0287] As shown in FIG. 36A, offset numbers “1” and “3” are assigned to fieldA1 and fieldA2 of class A, respectively, and the getfield_b instruction or the getfield_s instruction is used according to the field type.

[0288] As shown in FIG. 36B, offset numbers “1” and “3” are assigned to fieldA1 and fieldA2 of class B in the same way as class A, where these fields have been inherited from class A. In addition, an offset number “5” is assigned to fieldB1 which is newly defined. One of the getfield_b, getfield_s, and getfield instructions is used according to the field type.

[0289] 1.9 Brief Account

[0290] As described above, the program execution system 1 extends the function of the light-weight base class library to achieve a desired operation by allowing a plurality of different types of terminal apparatuses to execute the same light-weight user class file which is transferred between the terminal apparatuses regardless of the terminal apparatus type. This eliminates the necessity of generating different light-weight user class files according to the light-weight base class library of each terminal apparatus.

[0291] Although the program execution system 1 using light-weight class files is suitable for low-performance terminal apparatuses such as a computer-integrated system, the use of the same light-weight user class file in a plurality of terminal apparatuses reduces the load on the program developers.

[0292] In the program execution system 1, the class-design-dependent fields are grouped for each base class file, a class-design-dependent field offset table is generated for each base class file, a class-design-non-dependent field offset table is associated with each base class file to be inherited, and a pointer pointing to an area corresponding to a class-design-dependent field offset table is stored at the start of an area corresponding to each base class file in the class-design-non-dependent field offset table. However, the pointer pointing to the area corresponding to the class-design-dependent field offset table may be stored at the last of the area corresponding to each base class file in the class-design-non-dependent field offset table.

[0293] In the program execution system 1, it is supposed that each class is classified into a user class or a base class. However, an intermediate class, such as an information service class may be defined as well. In this case, it is defined that the user classes cannot use the class-design-dependent fields of the information service classes and the base classes and that the information service classes cannot use the class-design-dependent fields of the base classes.

[0294] In the program execution system 1, the modifier “private” is used to define the class-design-dependent field. However, another keyword may be used instead to achieve the class-design-dependent field.

[0295] In the program execution system 1, a class-design-dependent field offset table is provided for each base class file. It is also possible to provide a program execution system 2 in which the class-design-dependent fields of all the base class files to be inherited are written in one class-design-dependent field offset table. It is also possible to provide a program execution system 3 in which the maximum number of instance fields to be used is estimated, and areas for the instance fields are allocated in advance in the class-design-non-dependent field offset table. The following are descriptions of the program execution systems 2 and 3 as the second and third embodiments of the present invention.

[0296] 2. Second Embodiment

[0297] The program execution system 2 will be described as the second embodiment of the present invention.

[0298] The program execution system 2 has the same construction and operates the same as the program execution system 1 except for the construction of the class-design-non-dependent field offset table and the class-design-dependent field offset table, and the operation related to this change in the construction.

[0299] Note that in the following description, as is the case with the conventional program execution system, it is supposed that the Java programs shown in FIGS. 1 to 3 are used via compilation.

[0300] 2.1 Construction of Program Execution System 2

[0301] (a) Field Offset Table Corresponding to Base Class

[0302]FIG. 37 shows two class-design-non-dependent field offset tables that are generated to correspond to base classes. FIGS. 38A and 38B show class-design-dependent field offset tables that are generated to correspond to base classes.

[0303] As shown in the class-design-non-dependent field offset table shown in FIG. 37 that corresponds to the base class Built_in_classX, offset numbers “2” and “3” are assigned to the class-design-non-dependent fields “fieldX1” and “fieldX2”, respectively, in the order of definition.

[0304] With the above construction, the operands written in the base class file and used in the getfield and putfield instructions to indicate “fieldX1” and “fieldX2” in the constant pool are written as “2” and “3”, respectively, in the light-weight base class file when the terminal apparatus generates an instance, to indicate offsets with reference to the start of the instance area.

[0305] The “null” in the area in the “instance field” column corresponding to the field offset number “1” shows that the instance field “null” stores a pointer when a terminal apparatus generates an instance, the pointer pointing to an area corresponding to the class-design-dependent field offset table. The “null” used in the class-design-non-dependent field offset table means the same as the class-design-non-dependent field offset table for the base class Built_in_classX shown in FIG.

[0306] As shown in the class-design-non-dependent field offset table shown in FIG. 37 that corresponds to the base class Built_in classy, offset numbers “2”, “3”, “4”, “5”, and “6” are assigned, in the order of definition, to (1) the class-design-non-dependent fields “fieldX1” and “fieldX2” inherited from the base class Built_in_classX and (2) the class-design-non-dependent fields “fieldY1”, “fieldY2”, and “fieldY3” newly defined in the base class Built_in_classY.

[0307] With the above construction, the operands written in the base class file and used in the getfield and putfield instructions to indicate “fieldX1”, “fieldX2”, “fieldY1”, “fieldY2”, and “fieldY3” in the constant pool are written as “2”, “3”, “4”, “5”, and “6”, respectively, in the light-weight base class file when the terminal apparatus generates an instance, to indicate offsets with reference to the start of the instance area.

[0308] The “null” in the area in the “instance field” column corresponding to the field offset number “1” in the class-design-non-dependent field offset table for the base class Built_in_classY shows that the instance field “null” stores a pointer when a terminal apparatus generates an instance, the pointer pointing to an area corresponding to the class-design-dependent field offset table.

[0309] The class-design-non-dependent field offset table for the base class Built_in_classY shown in FIG. 37 shows only one instance field “null” while the one shown in FIG. 11 includes two instance fields “null”. That is to say, the class-design-non-dependent field offset table for the base class Built_in_classY shown in FIG. 37 provides only one area for storing a pointer pointing to an area corresponding to the class-design-dependent field offset table, covering the two base classes Built_in_classX and Built_in_classY. The class-design-non-dependent field offset table for the base class Built_in_classY shown in FIG. 37 also provides relationships between offset numbers and the class-design-dependent fields of these base classes successively.

[0310] These class-design-non-dependent field offset tables shown in FIG. 37 are common to the terminal apparatuses A and B. However, the terminal apparatuses A and B use different class-design-dependent field offset tables.

[0311] More specifically, for terminal apparatus A, class-design-dependent field offset tables shown in FIG. 38A are generated for the base classes, respectively. Also, for terminal apparatus B, class-design-dependent field offset tables shown in FIG. 38B are generated for the base classes, respectively. These class-design-dependent field offset tables shown in FIGS. 38A and 0.38B differ from those shown in FIGS. 12A and 12B in that each class-design-dependent field offset table for Built_in_classY includes the contents of the corresponding class-design-dependent field offset table for Built_in_classX.

[0312] (b) User Class Class-Design-Non-Dependent Field Offset Tables

[0313]FIG. 39 shows the class-design-non-dependent field offset table corresponding to the user class User_class shown in FIG. 3. FIGS. 40A and 40B show the instances corresponding to the user classes User_class generated in the terminal apparatuses A and B, respectively.

[0314] As shown in the user class class-design-non-dependent field offset table shown in FIG. 39, offset numbers “2”, “3”, “4”, “5”, and “6” are assigned to the class-design-non-dependent fields inherited from the base class Built_in_classY, where the offset numbers are the same as those assigned for the base class Built_in_classY. In this table shown in FIG. 39, offset numbers “7” and “8” are also assigned to the class-design-non-dependent fields which are newly defined in this table.

[0315] In the user class class-design-non-dependent field offset table shown in FIG. 39, offset number “1” is assigned to the instance field “null”. This indicates that the same pointer is stored in the same area as indicated in the class-design-non-dependent field offset table for the base class Built_in_classY.

[0316] As shown in FIG. 40A, a memory area 721 corresponding to the user class class-design-non-dependent field offset table shown in FIG. 39 is allocated for the terminal apparatus A. Then, a memory area 722 corresponding to the class-design-dependent field offset table for the base class Built_in_classY shown in FIG. 38A is allocated. The memory area 721 includes a pointer area corresponding to the instance field “null”. A pointer is stored into the pointer area, where the pointer points to the memory area 722 that corresponds to the class-design-dependent field offset table for the base class Built_in_classy. In this way, instances for the terminal apparatus A are generated.

[0317] Similarly, as shown in FIG. 40B, a memory area 731 corresponding to the user class class-design-non-dependent field offset table shown in FIG. 39 is allocated for the terminal apparatus B. Then, a memory area 732 corresponding to the class-design-dependent field offset table for the base class Built_in_classY shown in FIG. 38B is allocated. The memory area 731 includes a pointer area corresponding to the instance field “null”. A pointer is stored into the pointer area, where the pointer points to the memory area 732 that corresponds to the class-design-dependent field offset table for the base class Built_in_classY. In this way, instances for the terminal apparatus B are generated.

[0318] (c) Field Count Table

[0319] The field count tables used in the program execution system will be described.

[0320] Base Class Class-Design-non-Dependent Field Count Table

[0321]FIG. 41 shows a class-design-non-dependent field count table included in a light-weight base class file for the terminal apparatuses A and B.

[0322] The class-design-non-dependent field count table shown in FIG. 41 includes class IDs, non-dependent field counts, and super class IDs. The class IDs, non-dependent field counts, and super class IDs will not be detailed here since they have already been explained earlier.

[0323] Base Class Class-Design-Dependent Field Count Table

[0324]FIGS. 42A and 42B show class-design-dependent field count tables included in light-weight base class files for the terminal apparatuses A and B.

[0325] These class-design-dependent field count tables each include class IDs and dependent field counts. The class IDs and dependent field counts will not be detailed here since they have already been explained earlier.

[0326] User Class Class-Design-Non-Dependent Field Count Table

[0327]FIG. 43 shows a class-design-non-dependent field count table included in a light-weight user class file for the terminal apparatuses A and B.

[0328] The class-design-non-dependent field count table includes class IDs, non-dependent field counts, and super class IDs. The class IDs, non-dependent field counts, and super class IDs will not be detailed here since they have already been explained earlier.

[0329] (d) Specific Examples of Instruction Conversion

[0330] Specific examples of instruction conversion will be shown.

[0331] As shown in FIG. 44A, in the class file, before conversion, for the base class Built_in_classY for the terminal apparatus A, operand <Built_in_classY.fieldY1> of the putfield instruction and operand <Built_in_classY.privateY1> of the putfield instruction indicate offsets in the constant pool. The instruction conversion unit of the program execution system 2 converts the offsets into offset numbers that identify instance fields in the instance area, based on the above described instance field offset tables. The instruction conversion unit also converts operand <Built_in_classY> of the “new” instruction into a certain number. As a result of this, the class file shown in FIG. 44B is obtained. As shown in FIG. 44B, each operand of the putfield and getfield instructions is converted into “4”. Also, “dependent” is attached to the putfield instruction.

[0332] As shown in FIG. 45A, in the class file, before conversion, for an ordinary Java user class, operand <User_class.fieldU1> of the putfield instruction indicates an offset in the constant pool. The instruction conversion unit of the program execution system 2 converts the offset into an offset number that identifies an instance field in the instance area, based on the above described instance field offset tables. The instruction conversion unit also converts operand <User_class> of the “new” instruction into a certain number. As a result of this, the class file shown in FIG. 45B is obtained. As shown in FIG. 45B, the operand of the putfield instruction is converted into

[0333] 2.2 Operation of Program Execution System 2

[0334] The operation of the program execution system 2 will be described. Here, what is different from the program execution system 1 will be mainly described.

[0335] (1) Operation of Linkage to Base Class File

[0336] The procedure for the linkage to the base class files will be described.

[0337] Operation of Offset Table Generation Unit 13

[0338] The offset table generation process performed by the offset table generation unit 13 of the program execution system 2 in step S104 a will be detailed with reference to the flowchart shown in FIG. 46.

[0339] The steps in FIG. 46 having the same numbers as the flowchart shown in FIG. 26 will not be explained here since the same operations are performed in these steps.

[0340] After step S107 b is completed, the offset table generation unit 13 writes a non-dependent field of the target class into the class-design-non-dependent field offset table for the super class shown in FIG. 37, and outputs the class-design-non-dependent field offset table to the instruction conversion unit 14. In this step, when the target class does not have a super class, the offset table generation unit 13 generates a class-design-non-dependent field offset table from the non-dependent field of the target class, and adds one pointer area for storing a pointer pointing to a dependent field, to the start of the generated class-design-non-dependent field offset table (step S401). The offset table generation unit 13 then writes the class ID, non-dependent field count, and super class ID of the target class into the class-design-non-dependent field count table shown in FIG. 41. In doing this, the non-dependent field count is obtained by counting the non-dependent fields based on the class-design-non-dependent field offset table, including the pointer area at the start of the table and non-dependent fields which are inherited from other classes (step S402).

[0341] The offset table generation unit 13 then generates the class-design-dependent field offset table shown in FIG. 38 using only dependent fields of the target class, and outputs the table to the instruction conversion unit 14 (step S403). The offset table generation unit 13 writes the class ID, non-dependent field offset and non-dependent field count of the target class into the class-design-dependent field count table shown in FIG. 42. In doing this, the non-dependent field count is obtained by counting the dependent fields of the target class based on the generated class-design-dependent field offset table, including dependent fields which are inherited from other classes (step S404). Control then moves to step S109.

[0342] Operation of Instruction Conversion Unit 14

[0343] The instruction conversion performed by the instruction conversion unit 14 of the program execution system 2 in step S110 a will be described in detail with reference to the flowchart shown in FIG. 47.

[0344] The steps in FIG. 47 having the same numbers as the flowchart shown in FIG. 27 will not be explained here since the same operations are performed in these steps.

[0345] After step S111 a is completed, the instruction conversion unit 14, in step S411, performs the instruction conversion by adding the dependent modification instruction to the access instruction, and referring to the dependent field count table of the target class to set the non-depended field offset to the first operand. In this step, “putfield <Built_in_classY. privateY1>” shown in FIG. 44A is converted into “dependent putfield 4” as shown in FIG. 44B.

[0346] In step S111 e, the instruction conversion unit 14 refers to the class ID table to perform the instruction conversion by changing the class name to the class ID. In this step, “new <Built_in_classY>” shown in FIG. 44A is converted into “new 2” as shown in FIG. 44B.

[0347] (2) Operation of Linkage to User Class File

[0348] The procedure for the linkage to the user class files will be described.

[0349] Operation of Offset Table Generation Unit 13

[0350] The offset table generation process performed by the offset table generation unit 13 of the program execution system 2 in step S205 a will be described in detail using the flowchart shown in FIG. 48.

[0351] The steps in FIG. 48 having the same numbers as the flowchart shown in FIG. 29 will not be explained here since the same operations are performed in these steps.

[0352] After step S208 b is completed, the offset table generation unit 13 generates the class-design-non-dependent field offset table shown in FIG. 39, and outputs the table to the instruction conversion unit 14 (step S421).

[0353] The offset table generation unit 13 then writes the class ID, non-dependent field count, and super class ID of the target class into the class-design-non-dependent field count table shown in FIG. 43 (step S422).

[0354] After step S422 is completed, control moves to step S209.

[0355] Operation of Instruction Conversion Unit 14

[0356] The instruction conversion performed by the instruction conversion unit 14 of the program execution system 2 in step S210 a will be described in detail with reference to the flowchart shown in FIG. 49.

[0357] The steps in FIG. 49 having the same numbers as the flowchart shown in FIG. 30 will not be explained here since the same operations are performed in these steps.

[0358] When judging positively in step S210, the instruction conversion unit 14 performs the instruction conversion by referring to the non-dependent field offset table of the target class to set the non-depended field offset to the first operand (step S431). In this step, “putfield <User_class.fieldU1>” shown in FIG. 45A is converted into “putfield 7” as shown in FIG. 45B. Control then returns to step S210 to repeat the steps.

[0359] When judging positively in step S211 b, the instruction conversion unit 14 performs the instruction conversion by referring to the class ID correspondence table to change the class name to the class ID (step S432). In this step, “new <User_class>” shown in FIG. 45A is converted into “new 8001” as shown in FIG. 45B. Control then returns to step S211 b to repeat the steps.

[0360] (3) Operation of Instruction Execution by Terminal Apparatus 20

[0361] The procedure for the instruction execution process performed by the terminal apparatus 20 will be described using the flowcharts shown in FIGS. 50 and 51.

[0362] The steps in FIG. 50 having the same numbers as the flowchart shown in FIG. 31 will not be explained here since the same operations are performed in these steps. Also, the steps in FIG. 51 having the same numbers as the flowchart shown in FIG. 32 will not be explained here since the same operations are performed in these steps.

[0363] After step S304 is completed, the instruction generation unit 22 reads the class-design-non-dependent field count table from the light-weight user class file, and allocates an area X in a memory having a size enough to store as many fields as indicated by the non-dependent field count for the target class (step S441). An example of the allocated area X in the memory is shown in FIG. 40A, indicated by the reference sign “721”. After this step, control moves to step S306.

[0364] When the target class is a base class (“Yes” in step S306), the instance generation unit 22 reads the class-design-dependent field count table from the light-weight base class file, and allocates an area Y in a memory having a size enough to store as many fields as indicated by the dependent field count for the target class (step S442), and stores the pointer pointing to the area Y, into the first area in the area X (step S443). The relationship between area X and area Y is shown in FIG. 40A. In FIG. 40A, the sign “721” indicates the area X, and the sign “722” indicates the area Y. Control then moves to step S310.

[0365] When judging positively in step S314, the instruction execution unit 21 obtains the address of area Y that stores a pointer pointing to a dependent field area, by adding offset “1” to an address of an instance in a stack (step S444). The instruction execution unit 21 then obtains the address of area X that is a target of the putfield (getfield) instruction, by adding the first operand (a dependent field offset) of the selected instruction to an address pointed to by the pointer in the area Y (step S445).

[0366] Control then moves to step S317.

[0367] 2.3 Brief Account

[0368] Terminal apparatuses A and B generate the instances shown in FIGS. 40A and 40B. As a result, both terminal apparatuses A and B can access “fieldU1” of the user class User_class as the 7^(th) variable in the instance area.

[0369] As described above, as is the case with the program execution system 1, the program execution system 2 is suitable for low-performance terminal apparatuses such as a computer-integrated system. Also, the use of the same light-weight user class file in a plurality of terminal apparatuses reduces the load on the program developers.

[0370] The variations applied to the program execution system 1, such as changing the position of the pointer area in the class-design-dependent field offset table from the start to the last, can also applied to the program execution system 2.

[0371] 3. Third Embodiment

[0372] The program execution system 3 will be described as the third embodiment of the present invention.

[0373] The program execution system 3 has the same construction and operates the same as the program execution system 1 except for the construction of the class-design-non-dependent field offset table and the class-design-dependent field offset table, and the operation related to this change in the construction.

[0374] Note that in the following description, as is the case with the conventional program execution system, it is supposed that the Java programs shown in FIGS. 1 to 3 are used via compilation.

[0375]FIG. 52 shows two class-design-non-dependent field offset tables that are generated in the program execution system 3 to correspond to base classes. FIGS. 53A and 53B show instance field offset tables corresponding to the base classes.

[0376] In the program execution system 3, the maximum number of class-design-dependent fields to be included in the base class files is determined in advance. Designers design the base class files so that the number of class-design-dependent fields does not exceed the maximum number. The base class definition file includes only information concerning the maximum number of fixed-length class-design-dependent fields. It is supposed here that the maximum number of class-design-dependent fields is “5”, for example.

[0377] The program execution system 3 generates a non-dependent field count for each class, where the non-dependent field count indicates the number of non-dependent fields included in a class. The program execution system 3 then adds up, for each class, the non-dependent field count, a dependent field count being a fixed value, and a field count of a class which is inherited by the present class, generates a count table including the sum, and writes the generated count table to the light-weight class file.

[0378] Unlike the program execution system 1 or 2, the program execution system 3 does not newly generate class-design-dependent field count tables, but generate instance field offset tables by adding information concerning class-design-dependent fields to the class-design-non-dependent field offset tables. In the program execution system 3, a count table is generated, and a light-weight class file including the count table is transferred from the program generation apparatus 10 to the terminal apparatus 20.

[0379] As shown in the class-design-non-dependent field offset table for the base class Built_in_classX in FIG. 52, offset numbers “1” and “2” are assigned to the class-design-non-dependent fields “fieldX1” and “fieldX2”, respectively, in the order of definition. Also, offset numbers “3” to “7” are assigned to the class-design-dependent fields.

[0380] As shown in the class-design-non-dependent field offset table for the base class Built_in_classY in FIG. 52, offset numbers “1” and “2” are assigned to the class-design-non-dependent fields “fieldX1” and “fieldX2” that are inherited from the base class Built_in_classX, offset numbers “8”, “9”, and “10” are assigned to the class-design-non-dependent fields “fieldY1”, “fieldY2”, and “fieldY3” that are newly defined, and offset numbers “3” to “7” and “11” to “15” are assigned to the class-design-dependent fields.

[0381] The instance field offset tables for the terminal apparatuses A and B shown in FIGS. 53A and 53B are generated by adding the information concerning the class-design-dependent fields to the above-described class-design-non-dependent field offset tables.

[0382]FIG. 54 shows an instance field offset table generated in correspondence to the user class User_class shown in FIG. 3. FIGS. 55A and 55B show instances of the user classes User_class generated by the terminal apparatuses A and B.

[0383] In the program execution system 3, since the maximum number of class-design-dependent fields for use in each terminal apparatus is determined in advance, the instance field offset table for the user class User_class, as shown in FIG. 54, is used by both the terminal apparatuses A and B, and the light-weight user class file including the instance field offset table is also used by both terminal apparatuses A and B.

[0384] Actually, the terminal apparatuses A and B generate the instances shown in FIGS. 55A and 55B, respectively according to the instance field offset tables corresponding to the base classes and user classes (note that the instance field offset table shows relationships between the instance field types and offset numbers). More specifically, the terminal apparatuses A and B generate fixed-length instances. In FIGS. 55A and 55B, the instance includes 17 instance fields. The terminal apparatuses A and B secure each dependent instance field in the instance. The terminal apparatuses A and B read the count for each class from the light-weight class file, and secure as many instance fields as the read count for each class. As a result, both terminal apparatuses A and B can access “fieldU1” of the user class User_class as the 16^(th) variable.

[0385] As described above, as is the case with the program execution system 1, the program execution system 3 is suitable for low-performance terminal apparatuses such-as a computer-integrated system. Also, the use of the same light-weight user class file in a plurality of terminal apparatuses reduces the load on the program developers. Furthermore, since terminal apparatuses can keep on using conventional class files, a program execution system for reducing the load on the program developers can easily been installed.

[0386] In the program execution system 3 of the present embodiment, the base class definition file includes only information concerning the maximum number of class-design-dependent fields. However, the base class definition file may include information concerning other instance fields.

[0387] 4. Other Variations

[0388] Up to now, the present invention has been described through its embodiments. The present invention, however, is not limited to the above embodiments, and include the following variations.

[0389] (1) The present invention may be a method for achieving the above functions, or a computer program for allowing a computer to achieve the method, or a digital signal composed of the computer program.

[0390] The present invention may be a computer-readable record medium (e.g., a floppy disk, a hard disk, a CD-ROM, an MO, a DVD, a DVD-ROM, a DVD-RAM, or a semiconductor memory) recording the computer program or the digital signal. The present invention may be the computer program or the digital signal recorded in such a record medium.

[0391] The present invention may be the computer program or the digital signal transferred via a network such as an electric communication line, a radio or wired communication line, or the Internet.

[0392] The present invention may be a computer system having a microprocessor and a memory, where the memory prestores the computer program, and the microprocessor operates according to the computer program.

[0393] The computer program or the digital signal may be executed in another independent computer system by recording the computer program or the digital signal in the record medium and transferring the record medium to the other computer system, or by transferring the computer program or the digital signal via the above network to the other computer system.

[0394] The present invention has been fully described by way of examples with reference to the accompanying drawings, it is to be noted that various changes and modifications will be apparent to those skilled in the art. Therefore, unless such changes and modifications depart from the scope of the present invention, they should be construed as being included therein. 

1. A program generation apparatus for generating a plurality of light-weight class files for each terminal apparatus by linking a plurality of class files for each terminal apparatus, the program generation apparatus comprising: a storage means for prestoring the plurality of class files for each terminal apparatus, wherein each class defines (a) dependent variables unique to each terminal apparatus and (b) non-dependent variables common to all the plurality of terminal apparatuses, each variable is identified by a variable name, and each class file includes a variable name for each variable; an assignment means for assigning an offset number to each variable defined in the plurality of class files so that the same offset numbers are assigned to non-dependent variables having the same variable names; and a generation means for generating the plurality of light-weight class files for each terminal apparatus by replacing each variable name in each class file with an offset number assigned by the assignment means.
 2. The program generation apparatus of claim 1, wherein the assignment means assigns an offset number to each variable using different numbering systems for dependent variables and non-dependent variables.
 3. The program generation apparatus of claim 2, wherein the generation means further generates a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.
 4. The program generation apparatus of claim 2, wherein the plurality of classes include a first class and a second class which inherits the first class, and the assignment means assigns an offset number to each variable using, in terms of the second class, different numbering systems for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class.
 5. The program generation apparatus of claim 4, wherein the generation means further generates a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.
 6. The program generation apparatus of claim 2, wherein the plurality of classes include a first class and a second class which inherits the first class, and the assignment means assigns an offset number to each variable using, in terms of the second class, one numbering system for (a) dependent variables defined only in the second class and (b) dependent variables defined in the first class inherited by the second class.
 7. The program generation apparatus of claim 6, wherein the generation means further generates a non-dependent variable count and a dependent variable count for each class and adds to each light-weight class file the generated non-dependent variable count and the generated dependent variable count which indicate the number of non-dependent variables and the number of dependent variables included in a class, respectively.
 8. The program generation apparatus of claim 1, wherein the plurality of classes include a first class and a second class which inherits the first class, and the number assignment means assigns an offset number to each variable using one numbering system regardless of dependent variables or non-dependent variables, and provides, in terms of the second class, a predetermined space between (a) variables defined only in the second class and (b) variables defined in the first class inherited by the second class.
 9. The program generation apparatus of claim 8, wherein the generation means further generates a non-dependent variable count for each class, and adds the non-dependent variable count to a dependent variable count being a fixed value to obtain a count, and adds the obtained count to each light-weight class file.
 10. A virtual machine for operating according to a plurality of light-weight class files generated by the program generation apparatus defined in claim 1, comprising: a storage means for prestoring the plurality of light-weight class files; an instance generation means for reading the plurality of light-weight class files and generating an instance according to offset numbers for variables included in the plurality of light-weight class files; and an execution means for executing instructions defined in the plurality of light-weight class files, using the generated instance.
 11. A virtual machine for operating according to a plurality of light-weight class files generated by the program generation apparatus defined in claim 3, comprising: a storage means for prestoring the plurality of light-weight class files; an instance generation means for generating an instance by (a) reading the plurality of light-weight class files, (b) allocating a first area and a second area in a memory based on, respectively, non-dependent variable counts and dependent variable counts generated for each class and included in the read light-weight class files, and (c) storing in the second area a pointer pointing to the first area; and an execution means for executing instructions defined in the plurality of light-weight class files, using the generated instance.
 12. A program generation method for use in a program generation apparatus which generates a plurality of light-weight class files for each terminal apparatus by linking a plurality of class files for each terminal apparatus, the program generation apparatus including a storage means for prestoring the plurality of class files for each terminal apparatus, wherein each class defines (a) dependent variables unique to each terminal apparatus and (b) non-dependent variables common to all the plurality of terminal apparatuses, each variable is identified by a variable name, and each class file includes a variable name for each variable, and the program generation method comprising: an assignment step for assigning an offset number to each variable defined in the plurality of class files so that the same offset numbers are assigned to non-dependent variables having the same variable names; and a generation step for generating the plurality of light-weight class files for each terminal apparatus by replacing each variable name in each class file with an offset number assigned in the assignment step.
 13. A computer-readable record medium recording a computer program for use in a computer which generates a plurality of light-weight class files for each terminal apparatus by linking a plurality of class files for each terminal apparatus, the computer including a storage means for prestoring the plurality of class files for each terminal apparatus, wherein each class defines (a) dependent variables unique to each terminal apparatus and (b) non-dependent variables common to all the plurality of terminal apparatuses, each variable is identified by a variable name, and each class file includes a variable name for each variable, and the computer program comprising: an assignment step for assigning an offset number to each variable defined in the plurality of class files so that the same offset numbers are assigned to non-dependent variables having the same variable names; and a generation step for generating the plurality of light-weight class files for each terminal apparatus by replacing each variable name in each class file with an offset number assigned in the assignment step.
 14. A program execution method for use in a virtual machine which operates according to a plurality of light-weight class files generated by the program generation apparatus defined in claim 1, the virtual machine including a storage means for prestoring the plurality of light-weight class files, and the program execution method comprising: an instance generation step for reading the plurality of light-weight class files and generating an instance according to offset numbers for variables included in the plurality of light-weight class files; and an execution step for executing instructions defined in the plurality of light-weight class files, using the generated instance.
 15. A computer-readable record medium recording a computer program for use in a virtual machine which operates according to a plurality of light-weight class files generated by the program generation apparatus defined in claim 1, the virtual machine including a storage means for prestoring the plurality of light-weight class files, and the computer program comprising: an instance generation step for reading the plurality of light-weight class files and generating an instance according to offset numbers for variables included in the plurality of light-weight class files; and an execution step for executing instructions defined in the plurality of light-weight class files, using the generated instance.
 16. A computer-readable record medium recording a plurality of light-weight class files generated by the program generation apparatus defined in claim
 1. 17. A program generation apparatus comprising a class file generation mechanism for generating a plurality of terminal specific class files for each of a plurality of classes from one or more input files comprising both terminal apparatus specific variables and terminal apparatus independent variables, and generating the plurality of terminal specific class files comprises replacing both terminal apparatus specific variables and terminal apparatus independent variables with offset values, wherein: the offset value used to replace any particular terminal apparatus independent variable in a terminal specific class file is the same value that is used to replace the particular terminal apparatus independent variable in all the other terminal specific class files of the generated plurality of terminal specific class files. 